<?php

/*********************************************************************************/
/* CNB Your Account: An Advanced User Management System for phpnuke     		*/
/* ============================================                         		*/
/*                                                                      		*/
/* Copyright (c) 2004 by Comunidade PHP Nuke Brasil                     		*/
/* http://dev.phpnuke.org.br & http://www.phpnuke.org.br                		*/
/*                                                                      		*/
/* Contact author: escudero@phpnuke.org.br                              		*/
/* International Support Forum: http://ravenphpscripts.com/forum76.html 		*/
/*                                                                      		*/
/* This program is free software. You can redistribute it and/or modify 		*/
/* it under the terms of the GNU General Public License as published by 		*/
/* the Free Software Foundation; either version 2 of the License.       		*/
/*                                                                      		*/
/*********************************************************************************/
/* CNB Your Account it the official successor of NSN Your Account by Bob Marion	*/
/*********************************************************************************/

if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {
    header("Location: ../../../index.php");
    die ();
}
if (!defined('CNBYA')) { echo "CNBYA protection"; exit; }

    if ($ya_config['expiring']!=0) {
        $past = time()-$ya_config['expiring'];
		$res = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users_temp WHERE time < '$past'");
		while (list($uid) = $db->sql_fetchrow($res)) {
                  $uid = intval($uid);
		  $db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE user_id = $uid");
		  $db->sql_query("DELETE FROM ".$user_prefix."_cnbya_value_temp WHERE uid = '$uid'");
		}
		
		$db->sql_query("OPTIMIZE TABLE ".$user_prefix."_cnbya_value_temp");
		$db->sql_query("OPTIMIZE TABLE ".$user_prefix."_users_temp");
    }

    $username  = trim(check_html($username, 'nohtml'));
    $check_num = trim(check_html($check_num, 'nohtml'));
    $result    = $db->sql_query("SELECT * FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'");
    if ($db->sql_numrows($result) == 1) {
        $row = $db->sql_fetchrow($result);
    $ya_username=$row[username];
    $ya_realname=$row[realname];
    $ya_useremail=$row[user_email];
	$user_telefon=$row[user_telefon];
	$city_id=$row[city_id];
	$user_meslek=$row[user_meslek];
	$country_id=$row[country_id];
    $ya_time=$row[time];
        $lv = time();
        include("header.php");
        title(_PERSONALINFO);
        OpenTable();
        echo "<table class='forumline' cellpadding=\"3\" cellspacing=\"3\" border=\"0\" width='100%'>\n";
        echo "<tr><td align=\"center\" bgcolor='$bgcolor2' colspan=\"2\"><b>"._FORACTIVATION."</b>:</td></tr>\n";
        echo "<form name=\"Register\" action=\"modules.php?name=$module_name\" method=\"post\">\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._USRNICKNAME.":</td><td bgcolor='$bgcolor1'>$ya_username</td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._UREALNAME.":<br>"._REQUIRED."</td><td bgcolor='$bgcolor1'>";
        echo "<input type=\"text\" name=\"realname\" value=\"$ya_realname\" size=\"50\" maxlength=\"60\"></td></tr>\n";
		if ($ya_config['telcontrol']==0) {
        echo "<tr><td bgcolor='$bgcolor2'>"._TELEFON.":<br>"._REQUIRED."</td><td bgcolor='$bgcolor1'>";
        echo "<input type=\"text\" name=\"user_telefon\" value=\"$user_telefon\" size=\"50\" maxlength=\"60\"></td></tr>\n";
		}
		if ($ya_config['meslekcontrol']==0) {
        echo "<tr><td bgcolor='$bgcolor2'>"._MESLEK.":<br>"._REQUIRED."</td><td bgcolor='$bgcolor1'>";
        echo "<input type=\"text\" name=\"user_meslek\" value=\"$user_meslek\" size=\"50\" maxlength=\"60\"></td></tr>\n";
		}
if ($ya_config['ulkecontrol']==0) {
echo "<tr><td bgcolor='$bgcolor2'><b>"._ULKE.":</b></td><td bgcolor='$bgcolor1'><select name='country_id'>\n";

$row = $db->sql_fetchrow($db->sql_query("SELECT ulke_id, ulke_adi FROM ".$prefix."_cnbya_ulkeler"));
$result = mysql_query ($row);
echo "<option $sel value='$country_id'>$country_id</option>\n";
while($row = $db->sql_fetchrow($result)) {
  $ulke_id = $row['ulke_id'];
  $ulke_adi = $row['ulke_adi'];
  if($ulke_id == $ulke_id) { $sel = "selected "; }
  echo "<option value='$ulke_adi'>$ulke_adi</option>\n";
  $sel = "";
}
$db->sql_freeresult($result);
echo "</select></td></td></tr>\n";
}
if ($ya_config['citycontrol']==0) {
echo "<tr><td bgcolor='$bgcolor2'><b>"._CITY.":</b></td><td bgcolor='$bgcolor1'><select name='city_id'>\n";

$row = $db->sql_fetchrow($db->sql_query("SELECT sehir_id, sehir_adi FROM ".$prefix."_cnbya_sehir"));
$result = mysql_query ($row);
echo "<option $sel value='$city_id'>$city_id</option>\n";
while($row = $db->sql_fetchrow($result)) {
  $sehir_id = $row['sehir_id'];
  $sehir_adi = $row['sehir_adi'];
  if($sehir_id == $sehir_id) { $sel = "selected "; }
  echo "<option value='$sehir_adi'>$sehir_adi</option>\n";
  $sel = "";
}
$db->sql_freeresult($result);
echo "</select></td></td></tr>\n";
}
        echo "<tr><td bgcolor='$bgcolor2'>"._UREALEMAIL.":</td>";
        echo "<td bgcolor='$bgcolor1'>$ya_useremail</td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._UFAKEMAIL.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"femail\" value=\"\" size=\"50\" maxlength=\"255\"><br>"._EMAILPUBLIC."</td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YOURHOMEPAGE.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_website\" value=\"\" size=\"50\" maxlength=\"255\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YICQ.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_icq\" value=\"\" size=\"30\" maxlength=\"100\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YAIM.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_aim\" value=\"\" size=\"30\" maxlength=\"100\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YYIM.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_yim\" value=\"\" size=\"30\" maxlength=\"100\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YMSNM.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_msnm\" value=\"\" size=\"30\" maxlength=\"100\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YLOCATION.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_from\" value=\"\" size=\"30\" maxlength=\"100\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YOCCUPATION.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_occ\" value=\"\" size=\"30\" maxlength=\"100\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._YINTERESTS.":<br>"._OPTIONAL."</td>";
        echo "<td bgcolor='$bgcolor1'><input type=\"text\" name=\"user_interests\" value=\"\" size=\"30\" maxlength=\"100\"></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._RECEIVENEWSLETTER.":</td><td bgcolor='$bgcolor1'><select name='newsletter'>";
        echo "<option value=\"1\">"._YES."</option><option value=\"0\" selected>"._NO."</option></select></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._ALWAYSSHOWEMAIL.":</td><td bgcolor='$bgcolor1'><select name='user_viewemail'>";
        echo "<option value=\"1\">"._YES."</option><option value=\"0\" selected>"._NO."</option></select></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._HIDEONLINE.":</td><td bgcolor='$bgcolor1'><select name='user_allow_viewonline'>";
        echo "<option value=\"0\">"._YES."</option><option value=\"1\" selected>"._NO."</option></select></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._FORUMSTIME."</td><td bgcolor='$bgcolor1'><select name='user_timezone'>";
        $utz = date("Z");
        $utz = round($utz/3600);
        for ($i=-12; $i<13; $i++) {
            if ($i == 0) {
                $dummy = "GMT";
            } else {
                if (!ereg("-", $i)) { $i = "+$i"; }
                $dummy = "GMT $i "._HOURS."";
            }
            if ($utz == $i) {
                echo "<option name=\"user_timezone\" value=\"$i\" selected>$dummy</option>";
            } else {
                echo "<option name=\"user_timezone\" value=\"$i\">$dummy</option>";
            }
        }
        echo "</select></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._FORUMSDATE.":<br>"._FORUMSDATEMSG."</td><td bgcolor='$bgcolor1'>";
        echo "<input type=\"text\" name=\"user_dateformat\" value=\"Y-m-d, H:i:s\" size='15' maxlength='14'></td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._SIGNATURE.":<br>"._OPTIONAL."<br>"._NOHTML."</td>";
        echo "<td bgcolor='$bgcolor1'><textarea wrap=\"virtual\" cols=\"50\" rows=\"5\" name=\"user_sig\">$userinfo[user_sig]</textarea><br>"._255CHARMAX."</td></tr>\n";
        echo "<tr><td bgcolor='$bgcolor2'>"._EXTRAINFO.":<br>"._OPTIONAL."<br>"._NOHTML."</td>";
        echo "<td bgcolor='$bgcolor1'><textarea wrap=\"virtual\" cols=\"50\" rows=\"5\" name=\"bio\">$userinfo[bio]</textarea><br>"._CANKNOWABOUT."</td></tr>\n";
        echo "<input type=\"hidden\" name=\"ya_username\" value=\"$ya_username\">";
        echo "<input type=\"hidden\" name=\"check_num\" value=\"$check_num\">\n";
        echo "<input type=\"hidden\" name=\"ya_time\" value=\"$ya_time\">\n";
        echo "<input type=\"hidden\" name=\"op\" value=\"saveactivate\">";
        echo "<tr><td bgcolor='$bgcolor1' colspan='2' align='center'><input type=\"submit\" value=\""._SAVECHANGES."\"></td></tr>\n";
        echo "</form>\n";
        echo "</table>\n";
        CloseTable();
        include("footer.php");
        die();
    } else {
        include("header.php");
        title(""._ACTIVATIONERROR."");
        OpenTable();
        echo "<center>"._ACTERROR."</center>";
        CloseTable();
        include("footer.php");
        die();
    }

?>